<template>
	<view class="car-ptf-page">
		<view class="header">
			<view class="left" @click="onDateClick">
				<text>接车日期：</text>
				<view class="date" >
					<text>{{time}}</text>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<u-icon @click="onAdd" name="plus" color="#fff" size="38"></u-icon>
		</view>	
		<view class="car-pft-list">
			<PftList :timestamp="timestamp"/>
		</view>
		<u-picker v-model="pickDate" mode="time" @confirm="getDate"></u-picker>
	</view>
</template>

<script>
	import PftItem from './components/carPftListItem.vue';
	import PftList from './components/PtfList.vue';
	
	export default {
		components: {
			PftItem,
			PftList
		},
		created(){
			let date = new Date()
			this.time = date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate()
			this.timestamp = parseInt((date.getTime()/1000))
		},
		data() {
			return {
				time:null,
				pickDate:false,
				timestamp:null
			}
		},
		methods: {
			// 点击接车日期
			onDateClick() {
				this.pickDate = true 
			},
			// 点击新增图标
			onAdd() {
				// console.log(123)
				const option = {
					type : 'add'
				}
				this.$store.commit('formType','add')
				this.$store.commit('formDetail',{})
				this.$navTo.togo('/pages/views/carPreFlight/carPreDetails',option)
			},
			// 获取时间
			getDate(v){
				this.time = v.year + '-' + v.month + '-' + v.day
				this.timestamp = v.timestamp
				console.log(v)
			}
		}
	}
</script>

<style scoped lang="scss">
	.car-ptf-page{
		padding: 84rpx 0 30rpx; 
	}
	.header {
		position: fixed;
		top: 0;
		left: 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
		z-index: 1000;
		width: 100%;
		padding: 6px 10px 10px;
		background: #4F75BE;
		
		.left {
			display: flex;
			align-items: center;
			font-size: 28rpx;
			color: #fff;
			
			.date {
				padding: 8rpx 10rpx;
				background: #7794CC;
				
				text {
					margin-right: 6rpx;
				}
			}
		}
	}
	.car-pft-list{
		padding: 0 30rpx;
	}
</style>
